From 5334214febf69d7e84642539543ef5277789cead Mon Sep 17 00:00:00 2001 From: "kaf24@localhost.localdomain" Date: Sat, 9 Dec 2006 15:04:27 +0000 Subject: [PATCH] pygrub tmp files should live in /var/run/ not /var/lib/, as they are indeed runtime only. Also fix a race condition in making the pygrub fifo. Signed-off-by: John Levon --- tools/pygrub/Makefile | 4 ++-- tools/pygrub/src/pygrub | 6 ++++-- tools/python/xen/xend/XendBootloader.py | 16 +++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile index da75bda4b0..2e7b3e4d21 100644 --- a/tools/pygrub/Makefile +++ b/tools/pygrub/Makefile @@ -12,11 +12,11 @@ build: ifndef XEN_PYTHON_NATIVE_INSTALL install: all CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" - $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen + $(INSTALL_DIR) -p $(DESTDIR)/var/run/xend/boot else install: all CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" - $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen + $(INSTALL_DIR) -p $(DESTDIR)/var/run/xend/boot endif .PHONY: clean diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index 64a3662704..8fb43ca680 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -514,14 +514,16 @@ if __name__ == "__main__": fs = fsimage.open(file, offset) kernel = fs.open_file(img.kernel[1],).read() - (tfd, fn) = tempfile.mkstemp(prefix="vmlinuz.", dir="/var/lib/xen") + (tfd, fn) = tempfile.mkstemp(prefix="boot_kernel.", + dir="/var/run/xend/boot") os.write(tfd, kernel) os.close(tfd) sxp = "linux (kernel %s)" %(fn,) if img.initrd: initrd = fs.open_file(img.initrd[1],).read() - (tfd, fn) = tempfile.mkstemp(prefix="initrd.", dir="/var/lib/xen") + (tfd, fn) = tempfile.mkstemp(prefix="boot_ramdisk.", + dir="/var/run/xend/boot") os.write(tfd, initrd) os.close(tfd) sxp += "(ramdisk %s)" %(fn,) diff --git a/tools/python/xen/xend/XendBootloader.py b/tools/python/xen/xend/XendBootloader.py index 879b39806d..48ebb55e66 100644 --- a/tools/python/xen/xend/XendBootloader.py +++ b/tools/python/xen/xend/XendBootloader.py @@ -12,11 +12,12 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import os, select, errno +import os, select, errno, stat import random import shlex from xen.xend import sxp +from xen.util import mkdir from XendLogging import log from XendError import VmError @@ -37,11 +38,16 @@ def bootloader(blexec, disk, quiet = 0, blargs = None, imgcfg = None): log.error(msg) raise VmError(msg) + mkdir.parents("/var/run/xend/boot/", stat.S_IRWXU) + while True: - fifo = "/var/lib/xen/xenbl.%s" % random.randint(0, 32000) - if not os.path.exists(fifo): - break - os.mkfifo(fifo, 0600) + fifo = "/var/run/xend/boot/xenbl.%s" %(random.randint(0, 32000),) + try: + os.mkfifo(fifo, 0600) + except OSError, e: + if (e.errno != errno.EEXIST): + raise + break child = os.fork() if (not child): -- 2.30.2